package com.design.pattern.behavior.command.general;

public class Client {
    public static void main(String[] args) {
        ICommand command = new ConcreteCommand();
        Invoker invoker = new Invoker(command);
        invoker.action();
    }

    public interface ICommand {
        void execute();
    }
    //执行者
    static class Receiver {
        public void action(){
            System.out.println("执行具体操作");
        }
    }
    static class ConcreteCommand implements ICommand {

        private Receiver receiver = new Receiver();
        @Override
        public void execute() {
            this.receiver.action();
        }
    }

    //请求者
    static class Invoker {
        private ICommand command;

        public Invoker(ICommand command) {
            this.command = command;
        }

        public void action(){
            this.command.execute();
        }
    }
}
